package com.itheima.studentmanager.utils;

/**
 * The type Result.
 */
public class Result {
    private Integer code;//1 成功 , 0 失败
    private String msg; //提示信息
    private Object data; //数据 date

    /**
     * Instantiates a new Result.
     */
    public Result() {
    }

    /**
     * Instantiates a new Result.
     *
     * @param code the code
     * @param msg  the msg
     * @param data the data
     */
    public Result(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    /**
     * Gets code.
     *
     * @return the code
     */
    public Integer getCode() {
        return code;
    }

    /**
     * Sets code.
     *
     * @param code the code
     */
    public void setCode(Integer code) {
        this.code = code;
    }

    /**
     * Gets msg.
     *
     * @return the msg
     */
    public String getMsg() {
        return msg;
    }

    /**
     * Sets msg.
     *
     * @param msg the msg
     */
    public void setMsg(String msg) {
        this.msg = msg;
    }

    /**
     * Gets data.
     *
     * @return the data
     */
    public Object getData() {
        return data;
    }

    /**
     * Sets data.
     *
     * @param data the data
     */
    public void setData(Object data) {
        this.data = data;
    }

    /**
     * Success result.
     *
     * @param data the data
     * @return the result
     */
    public static Result success(Object data) {
        return new Result(1, "success", data);
    }

    /**
     * Success result.
     *
     * @return the result
     */
    public static Result success() {
        return new Result(1, "success", null);
    }

    /**
     * Error result.
     *
     * @param msg the msg
     * @return the result
     */
    public static Result error(String msg) {
        return new Result(0, msg, null);
    }


}
